package main

import "fmt"

//结构体定义  type关键字  结构体名字 struct关键字 {属性..}
type Person struct {
	Name string
	City string
	Age  int
}
type City struct {
	Name   string `json:"Name"`
	People string `json:"People"`
}

type MavenPackage struct {
	GroupId    string `json:"groupId"`
	ArtifactId string `json:"artifactId"`
	Version    string `json:"version"`
	RepoName   string `json:"repoName"`
	UpdateTime string `json:"updateTime"`
}

func main() {
	var p4 = new(MavenPackage)
	p4.GroupId = "com.org"
	p4.ArtifactId = "aac"
	p4.Version = "1.0-GA"
	p4.RepoName = "ReleaseLocal"
	p4.UpdateTime = "2022-11-13 20:12:21"

	var p5 = &MavenPackage{
		GroupId:    "org.sun",
		ArtifactId: "java",
		Version:    "2.0-GA",
		RepoName:   "ReleaseLocal",
		UpdateTime: "2022-11-13 20:12:21",
	}

	fmt.Println(p5.GroupId)
	//结构体实例化
	//方法1 值类型
	var p1 Person
	p1.Name = "张三"
	p1.City = "北京"
	p1.Age = 18
	fmt.Println(p1)
	//方法2 指针类型（推荐）
	var p2 = new(Person)
	p2.Name = "李四"
	p2.City = "上海"
	p2.Age = 20
	fmt.Println(p2)
	//方法3 指针类型（推荐）
	//var p3 = &Person{}
	var p3 = &Person{
		Name: "王五",
		City: "深圳",
		Age:  30,
	}
	fmt.Println(p3)
}
